<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>第三方用户列表</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="stylesheet" href="./css/frame/font.css">
		<link rel="stylesheet" href="./css/frame/xadmin.css">
		<link rel="stylesheet" href="./css/page/table.css" />
		<script type="text/javascript" src="./lib/jquery/jquery-3.3.1.min.js"></script>
		<script type="text/javascript" src="./lib/layui/layui.js"></script>
		<script type="text/javascript" src="./js/frame/xadmin.js"></script>
		<script type="text/javascript" src="./js/utils/TimeUtils.js"></script>
		<script type="text/javascript" src="./js/constant/urls.js"></script>
		<script type="text/javascript" src="./js/constant/constant.js"></script>
	</head>

	<body class="layui-anim layui-anim-up">
		<div class="x-nav">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
				<a href="">第三方用户管理</a>
				<a>
					<cite>第三方用户列表</cite></a>
			</span>
			<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
			 title="刷新">
				<i class="layui-icon" style="line-height:30px">ဂ</i></a>
		</div>
		<div class="x-body">
			<div class="demoTable condition">
				<div class="layui-inline">
					账号类型：
					<select name="accountType" id="accountType" style="width: 11.25rem; height: 2.375rem; font-size: 0.875rem;">
					</select>
				</div>
				账号搜索：
				<div class="layui-inline">
					<input class="layui-input head-search" name="account" id="demoReload" autocomplete="off">
				</div>
				<button class="layui-btn" data-type="reload">搜索</button>
			</div>
			<table class="layui-hide" id="LAY_table_user" lay-filter="tableFilter"></table>
		</div>
		<script>
			$(function() {
				$.ajax({
					type: "get",
					url: urls.sysUrl + 'dict/child/list/' + constant.thirdTypeCode,
					async: true,
					xhrFields: {
						withCredentials: true
					},
					success: function(res) {
						if (res.errorCode === 0) {
							$('#accountType').html("<option value=''>请选择账号类型</option>");
							for (let at of res.data) {
								$('#accountType').append("<option value='" + at.id + "'>" + at.name + "</option>");
							}
						}
					}
				});
				layui.use(['form', 'table'], function() {
					var table = layui.table,
						form = layui.form;
					//方法级渲染
					table.render({
						elem: '#LAY_table_user',
						url: urls.sysUrl + 'third/user/list',
						toolbar: '#toolbarDemo',
						parseData: function(res) { //res 即为原始返回的数据
							return {
								"code": res.errorCode, //解析接口状态
								"msg": res.description, //解析提示文本
								"count": res.extra, //解析数据长度
								"data": res.data //解析数据列表
							};
						},
						request: {
							pageName: 'pageNo',
							limitName: 'pageSize'
						},
						cols: [
							[{
								checkbox: true,
								fixed: 'left'
							}, {
								field: 'id',
								title: 'ID',
								hide: true
							}, {
								field: 'account',
								title: '第三方账号',
								width: 180
							}, {
								field: 'accountTypeName',
								title: '第三方账号类型',
								width: 180
							}, {
								field: 'loginName',
								title: '关联用户登录名',
								width: 180
							}, {
								field: 'mobilePhone',
								title: '关联用户手机号',
								width: 180
							}, {
								field: 'username',
								title: '关联用户用户名',
								width: 240
							}, {
								field: 'createByName',
								title: '创建人',
								width: 240,
							}, {
								field: 'createTime',
								title: '关联时间',
								sort: true,
								width: 240,
								templet: function(d) {
									return timestampToDateTime(d.createTime);
								}
							}]
						],
						id: 'testReload',
						page: true
					});
					var active = {
						reload: function() {
							var demoReload = $('#demoReload');
							//执行重载
							table.reload('testReload', {
								page: {
									curr: 1 //重新从第 1 页开始
								},
								where: {
									account: demoReload.val(),
									accountType: $('#accountType').val()
								}
							}, 'data');
						}
					};
					//删除添加操作的单击事件
					$('.demoTable .layui-btn').on('click', function() {
						var type = $(this).data('type');
						active[type] ? active[type].call(this) : '';
					});
					//执行重载
					function pageReload() {
						table.reload('testReload', {
							page: {
								curr: 1 //重新从第 1 页开始
							}
						});
					}
				});
			});
		</script>
	</body>

</html>
